<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/bootstrap-v4.6.0.css">
    <link rel="stylesheet" href="./css/login.css">
    <title>Document</title>
    <style>
        .login-box {
            width: 300px;
            height: 33px;
        }
    </style>
</head>

<body>
    <div class="login-box">
        <div class="form-group">
            <label for="username">Account</label>
            <!-- 账号 -->
            <input type="text" class="form-control" id="username" autocomplete="off">
            <small id="emailHelp" class="form-text text-muted">The available account is <strong>admin</strong></small>
        </div>
        <div class="form-group">
            <!-- 密码 -->
            <label for="password">Password</label>
            <input type="password" class="form-control" id="password">
            <small id="emailHelp" class="form-text text-muted">The available password is <strong>123456</strong></small>
        </div>
        <button type="submit" class="btn btn-primary" id="btnLogin">Submit</button>
    </div>
    <script src="../lib/jquery.js"></script>
    <script src="../lib/axios.js"></script>
    <script>
        //注册点击事件
        $('#btnLogin').on("click", function() {
            //2.实现注册，就是把用户的数据提交服务器
            //获取用户输入的数据
            let name = $("#username").val();
            let pwd = $("#password").val();
            //3.提交数据：
            axios({
                method: "POST",
                url: "http://www.liulongbin.top:3009/api/reg",
                data: {
                    //注意：参数名不能写错username password
                    username: name,
                    password: pwd
                }
            }).then(({
                data: res
            }) => {
                alert(res.msg)
            })
        });
    </script>

</body>

</html>